package com.heo.service.impl;

import java.util.HashMap;
import java.util.Map;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.heo.dao.BaseMapper;
import com.heo.dao.DeviceInfoMapper;
import com.heo.pojo.DeviceInfoEntity;
import com.heo.pojo.JsonArgs;
import com.heo.service.DeviceInfoService;

@Service("deviceInfoService")
public class DeviceInfoServiceImpl extends BaseServiceImpl<DeviceInfoEntity> implements DeviceInfoService {
	@Resource
	private DeviceInfoMapper deviceInfoMapper;

	@Override
	protected BaseMapper<DeviceInfoEntity> getDao() {
		return deviceInfoMapper;
	}

	@Override
	public boolean initDeviceInfo(JsonArgs jsonArgs) {
		String macAddress = jsonArgs.getM();
		Map<String, Object> paramMap = new HashMap<String, Object>();
//		paramMap.put("deviceImei", "000" + macAddress);
		paramMap.put("simId", jsonArgs.getI());
		paramMap.put("deviceSn", macAddress);
		paramMap.put("deviceMac", macAddress);
		long size = getDao().updateByMap(paramMap, "updateByMapMac");
		return (size > 0) ? true : false;
	}

	@Override
	public DeviceInfoEntity getDeviceInfoMap(String deviceMac) {
		return getDao().getByKey(deviceMac, "getByMac");
	}
}
